import { Component, Input } from '@angular/core';

import { NavController, NavParams } from 'ionic-angular';

import { ItemDetailsPage } from '../item-details/item-details';
import { Validators, FormBuilder, FormGroup, FormControl } from '@angular/forms';

@Component({
  selector: 'page-list',
  templateUrl: 'list.html'
})
export class ListPage {
  private axGroup: FormGroup;
  private model = {
    arrivedNumber: 12
  }
  @Input() icons: any;
  items: Array<{ title: string, note: string, icon: string }>;
  condition = true;
  color = "gray";
  evilTitle = 'Template <script>alert("evil never sleeps")</script>Syntax';

  constructor(public navCtrl: NavController,
    private formBuilder: FormBuilder,
    public navParams: NavParams) {
    this.icons = ['flask', 'wifi', 'beer', 'football', 'basketball', 'paper-plane',
      'american-football', 'boat', 'bluetooth', 'build'];

    this.items = [];
    for (let i = 1; i < 11; i++) {
      this.items.push({
        title: 'Item ' + i,
        note: 'This is item #' + i,
        icon: this.icons[Math.floor(Math.random() * this.icons.length)]
      });
    }



    this.axGroup =
      this.formBuilder
        .group({
          arrivedNumber: new FormControl('')
        });
  }

  itemTapped(event, item) {
    this.navCtrl.push(ItemDetailsPage, {
      item: item
    });
  }
}
